package com.hnit.rol.order.controller.user;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.hnit.rol.commonutils.Result;
import com.hnit.rol.model.entity.order.OrderInfo;
import com.hnit.rol.model.entity.order.OrderInfoShow;
import com.hnit.rol.model.vo.order.OrderInfoVo;
import com.hnit.rol.order.service.IOrderInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author King
 * @since 2023-04-09
 */
@RestController
@RequestMapping("user/order/payOrder")
public class PayOrderUserController {

    @Resource
    private IOrderInfoService orderInfoService;
    /**
     *生成订单信息，显示到页面
     */
    @GetMapping("generateOrder/{id}")
    public Result generatorOrderInfo(
            @PathVariable("id") Long id){
        OrderInfoShow orderInfo = orderInfoService.generateOrder(id);
        return Result.success(orderInfo);
    }
    /**
     * 点击 加入购物车,将数据存到订单表
     */
    @PostMapping("/insertShoppingCart")
    public Result insertShoppingCart(@RequestBody OrderInfo order){
        orderInfoService.insertShoppingCart(order);
       return Result.success();
    }

}
